<template>
  <div>
    <div v-if="isShow" :class="borderClass">
      <slot name="left"></slot>
      <!--    <i :class="iconClass"></i>-->
      <svg-icon :icon-class="iconClass"></svg-icon>
      <span>{{ title }}</span>
      <i
        v-if="canFold"
        :class="openClass"
        style="float: right"
        @click="clickMerge"
      ></i>
      <slot name="right"></slot>
    </div>
    <div v-else :class="borderClass">
      <slot name="left"></slot>
      <i :class="openClass" @click="clickMerge"></i>
      <slot name="right"></slot>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'SectionTitle',
    props: {
      title: {
        type: String,
        default: '',
      },
      iconClass: {
        type: String,
        default: 'title-default2',
      },
      openClass: {
        type: String,
        default: '',
      },
      borderBottom: {
        type: String,
        default: 'true',
      },
      canFold: {
        type: Boolean,
        default: true,
      },
    },
    data() {
      return {
        isShow: true,
        borderClass: {
          titleDiv:
            this.borderBottom == true ||
            this.borderBottom.trim() == 'true'.trim(),
        },
      }
    },
    created() {},
    methods: {
      clickMerge() {
        this.isShow = !this.isShow
        this.$emit('changePaneL')
      },
    },
  }
</script>
<style scoped>
  .titleDiv {
    border-bottom: 1px solid #e8e8e8;
  }
  div {
    padding: 7px;
  }
</style>
